﻿using System;
using Ease.EaseNode.Runtime;
using Ease.EaseNode.Runtime.Param;

namespace Ease.EaseMission.Runtime
{
    public class MATip : IMissionAgent
    {
        public IEaseNodeData Data { get; set; }
        private RunState currentState = RunState.NONE;

        public RunState CurrentState
        {
            get => currentState;
            set
            {
                if (currentState != value)
                {
                    OnRunStateChange?.Invoke(value);
                    OnValueChangeEvent?.Invoke(new StateChangeParam() {newState = (NodeState) value});
                }

                currentState = value;
            }
        }

        public event Action<RunState> OnRunStateChange;

        public MATip(IMissionParam param)
        {
            CurrentState = RunState.NONE;
        }

        public void Start()
        {
            CurrentState = RunState.RUNNING;
            TestTime.Instance.Delay(1f, () => { CurrentState = RunState.FINISH; });
        }

        public void Reset()
        {
            CurrentState = RunState.NONE;
        }

        public event Action<BaseChangeParam> OnValueChangeEvent;
        
    }
}